import { Module } from '@nestjs/common';
import { AdminController } from './admin.controller';
import { AdminService } from './admin.service';
import { ConfigureModule, ConfigureService } from '@app/configure';

import config from './config';
import { MemberModule } from './http/system/member/member.module';
import { DbModule } from './db/db.module';
import { CacheModule } from '@app/cache';
import { LoginModule } from './http/system/login/login.module';
import { ResponseUtilModule } from '@app/response-util';
import { MenuModule } from './http/system/menu/menu.module';
import { RoleModule } from './http/system/role/role.module';
import { AuthGuard } from './guard/auth/auth.guard';
import { APP_GUARD } from '@nestjs/core';
import { JwtVerifyModule } from '@app/jwt-verify';
import { DictionaryCategoryModule } from './http/system/dictionary-category/dictionary-category.module';
import { DictionaryItemModule } from './http/system/dictionary-item/dictionary-item.module';
import { SysConfigModule } from './http/system/sys-config/sys-config.module';;
import { UploadModule } from './http/upload/upload.module';
import { UserModule } from './http/user/user.module';
import { OfficialUserModule } from './http/official-user/official-user.module';
import { ImclientModule } from '@app/imclient';
import { NoticeModule } from './http/notice/notice.module';

@Module({
	imports: [
        JwtVerifyModule,
		ConfigureModule.forRoot(config),
        CacheModule,
		DbModule,

		ImclientModule.forRootAsync({
			inject : [ConfigureService],
			useFactory : async (config:ConfigureService) => {
				return {
					appKey: config.get('im.AppKey'),
					appSecret: config.get('im.AppSecret'),
				}
			},
		}),

		// MongodbModule,
		// AlicloudModule.forRootAsync({
		// 	imports : [ConfigureModule],
		// 	inject : [ConfigureService],
		// 	useFactory : (config:ConfigureService) => {
		// 		return {
		// 			...config.get('alicloud')
		// 		}
		// 	},
		// }),

        ResponseUtilModule,
		MemberModule,
		LoginModule,
		MenuModule,
		RoleModule,
		DictionaryCategoryModule,
		DictionaryItemModule,
		SysConfigModule,
		UploadModule,
		UserModule,
		OfficialUserModule,
		NoticeModule,
	],
	controllers: [AdminController],
	providers: [AdminService, {provide : APP_GUARD, useClass : AuthGuard}],
})
export class AdminModule {}
